// https://apis.netstart.cn/yunyuedu/store/navi.json?gender=2

import {getDecode } from '@/utils/decode.js'
const headerUrl = 'https://plomaster.cc/read/'

//获取首页分类
export const getHomeListType = ()=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}selectmuen`,
			method:'GET',
			success(conent) {
				
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
//获取首页分类详情
export const getDatas = (uuid)=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/selectmuendetails`,
			data:{
				id:uuid
			},
			method:'POST',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
//获取小说章节
export const getXiangQing = (id)=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/selectchapter?id=${id}`,
			method:'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
//获取小说章节详情
export const seletecontext = (id,ids)=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/seletecontext?source_uuid=${id}&content_uuid=${ids}`,
			method:'GET',
			success(conent) {
				if(conent.data.msg=='请求成功' ){
					let data  = getDecode(JSON.parse(conent.data.data[0].context))
					res(data)
				}else{
					let data = {
						code:200,
						msg:'您需要充值才能观看'
					}
					res(data)
				}
			},
			fail(err) {
				console.log(err);
				rej(err)
			}
		})
	})
}
//查询书籍
export const seletedata = (id)=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/seletedata?id=${id}`,
			method:'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
//根据类型查询数据
export const seletetypedata = (type,page,pageSize)=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/seletetypedata?type=${type}&page=${page}&pageSize=${pageSize}`,
			method:'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
//搜索数据
export const searchdata = (name)=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/searchdata?name=${name}`,
			method:'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
//查询首页小排行
export const selecthomesamlltag = ()=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/selecthomesamlltag`,
			method:'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}

//获取分类页面大分类
export const seletefenleitag = ()=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/seletefenleitag`,
			method:'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
//获取首页小排行详情
export const seletefenleitagdetails = (name)=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/seletefenleitagdetails?name=${name}`,
			method:'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
//查询是否收费
export const selectispaid = (id)=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/selectispaid?id=${id}`,
			method:'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
//推荐列表
export const randomdata = (id)=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/randomdata`,
			method:'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
//推荐列表
export const hotTuijian = ()=>{
	return new Promise((res, rej)=>{
		uni.request({
			url:`${headerUrl}/hotTuijian`,
			method:'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
